<template>
  <div>
    <div style="margin-bottom: 10px;">
      <el-button type="primary" icon="el-icon-plus" @click="add">新增仓库</el-button>
    </div>
    <el-table :data="list">
      <el-table-column type="index" label="序号"/>
      <el-table-column label="仓库名" prop="name"/>
      <el-table-column label="仓库说明" prop="info"/>
      <el-table-column label="仓库地址" prop="address"/>
      <el-table-column>
        <template slot-scope="scope">
          <el-button type="text" @click="edit">编辑</el-button>
          <el-button type="text" @click="del(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <storage-dialog ref="dialog" @ok="load"/>
  </div>
</template>

<script>
  import StorageDialog from "./storageDialog";

  export default {
    name: "stockList",
    components: {StorageDialog},
    data() {
      return {
        list: [],
        total: 0
      }
    },
    methods: {
      add() {
        console.log(this.$refs.dialog)
        this.$refs.dialog.show()
      },
      edit() {

      },
      del(v) {
        this.$confirm(`确定进行[删除]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          return this.$http({
            url: this.$http.adornUrl('/sys/storage/delStock'),
            method: 'get',
            params: this.$http.adornParams(
              {
                ids: v.id
              }
              // Object.assign(
              //   {
              //     current: page == null ? this.page.currentPage : page.currentPage,
              //     size: page == null ? this.page.pageSize : page.pageSize
              //   },
              //   params
              // )
            )
          })
        })
          .then(({data}) => {
            this.load()
          })
        console.log(arguments)
      },
      load() {
        this.$http({
          url: this.$http.adornUrl('/sys/storage/stockList'),
          method: 'get',
          params: this.$http.adornParams(
            // Object.assign(
            //   {
            //     current: page == null ? this.page.currentPage : page.currentPage,
            //     size: page == null ? this.page.pageSize : page.pageSize
            //   },
            //   params
            // )
          )
        }).then(({data}) => {
          this.list = data
        })
      }
    },
    mounted() {
      this.load()
    }
  }
</script>

<style scoped>

</style>
